package com.xj.listener;

import com.xj.pojo.Userrrr;
import com.xj.until.MailTestController;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.mail.MessagingException;

@Slf4j
@Component
public class SpringRabbitListener {
    @Autowired
    MailTestController mailTestController;

    @RabbitListener(queues = "simple.queue")
    public void listenSimpleQueue(Userrrr user) {

        System.out.println("这里用来发邮箱");
        System.out.println(user.getEmail());
        try {
            String s = mailTestController.sendHtmlMail111(user.getPassword(), user.getEmail());
            System.out.println(s);
        } catch (MessagingException e) {
            System.out.println("测试出错了");
            throw new RuntimeException(e);
        }
    }

}
